package demo11;

import demo5.DescIntWritable;
import org.apache.hadoop.io.IntWritable;

import java.util.TreeMap;

public class TestTreeMap {
    public static void main(String[] args) {
        // HashMap 底层是基于hash表实现的
        // TreeMap 根据key默认升序排序，底层是实现了comparable接口

        TreeMap<IntWritable,String> treeMap = new TreeMap();
        treeMap.put(new DescIntWritable(1),"zhangsan");
        treeMap.put(new DescIntWritable(8),"lisi");
        treeMap.put(new DescIntWritable(3),"wangwu");
        treeMap.put(new DescIntWritable(5),"zhaoliu");

//        System.out.println(treeMap.lastKey()); // 获取排序后的最后一位数
//        System.out.println(treeMap.size());

        System.out.println(treeMap.remove(treeMap.lastKey())); // 根据key 删除排序后的最后一组键值对

        System.out.println(treeMap);
    }
}
